// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   getAvailable.java

package stock;

import include.nseer_db.nseer_db;
import java.sql.ResultSet;

public class getAvailable
{

	public getAvailable()
	{
	}

	public double available(String unit_db_name, String stock)
	{
		nseer_db dba = new nseer_db(unit_db_name);
		double available_percent = 0.0D;
		try
		{
			String sql = (new StringBuilder("select sum(amount/max_capacity_amount) as sum1 from stock_balance_details where stock_name='")).append(stock).append("'").toString();
			ResultSet rs = dba.executeQuery(sql);
			double used_percent = 0.0D;
			if (rs.next())
				used_percent = rs.getDouble("sum1");
			available_percent = 1.0D - used_percent;
			dba.close();
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
		return available_percent;
	}
}
